package com.lrf.freeshipping.jdbc;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.lrf.freeshipping.tool.LogTool;

/**
 * 
 * @author LRF
 *
 */
public class DBconfig {
   private String driver;
   private String url;
   private String username;
   private String password;
   
   public DBconfig() {
	 InputStream is = null;
	 
     try {
    	 Properties p = new Properties();
	   // FileInputStream fis = new FileInputStream("WebRoot\\WEB-INF\\jdbc.properties");
       //p.load(fis);
    	is = this.getClass().getClassLoader().getResourceAsStream("../jdbc.properties");   	      
	    p.load(is);
	    this.driver = p.getProperty("jdbc.driver");
	    this.url = p.getProperty("jdbc.url");
	    this.username = p.getProperty("jdbc.username");
	    this.password = p.getProperty("jdbc.password");
     } catch (FileNotFoundException e) {
		LogTool.putLogs(e);
	} catch (IOException e) {
		LogTool.putLogs(e);
	}finally{
		if(is!=null){
			try {
				is.close();
			} catch (IOException e) {
				LogTool.putLogs(e);
			}
		}
	}
   
   }
   
   
   
   
public String getDriver() {
	return driver;
}
public void setDriver(String driver) {
	this.driver = driver;
}
public String getUrl() {
	return url;
}
public void setUrl(String url) {
	this.url = url;
}
public String getUsername() {
	return username;
}
public void setUsername(String username) {
	this.username = username;
}
public String getPassword() {
	return password;
}
public void setPassword(String password) {
	this.password = password;
}




@Override
public String toString() {
	return "DBconfig [driver=" + driver + ", url=" + url + ", username="
			+ username + ", password=" + password + "]";
}
	


	
}
